PADL Function
Syntax
Arguments
- C
A character string.
- length
A positive integer representing the length of the Formatted_String. If Length is less than len(Unformatted_String), then Unformatted_String will be truncated to Length. Numeric
- pad_string
The character string to append to the beginning of Unformatted_String to position it within Formatted_String.
Description
Pads the left side of a string with another string.
Discussion
PADL() pads a C_string on the left with a Pad_String, and returns a string of the specified Length. If the length of Pad_String + C_string is less than Length, the Pad_String is repeated to fill the remainder of the string. Note : PADL() or PADR() replicates the string specified as Pad_String to create a string of the specified length.
Example
The following expressions replicate a message to create a line for an invoice or receipt:
? padl(" ", 77, "Thank You ! ") = "Thank You ! Thank You ! Thank You ! Thank You ! Thank You ! Thank You ! " ? padl("$" + ltrim( str(200) ), 10, "*") = ******$200 ? padl(str(3,1),8,"0") = "00000003" Note : PADL() is often the best function for zero filling a field. dim myfield as C = " 100" ? myfield = " 100" ? padl(alltrim(myfield), len(myfield), "0") = "000000100"
See Also